#include "CCamera.h"

CCamera::CCamera()
{
	m_nCameraScreenPositionX = 0;
	m_nCameraScreenPositionY= 0;
	m_nCameraHeight = 0;
	m_nCameraWidth = 0;


	m_rCameraWorldPosition.top = 0;
	m_rCameraWorldPosition.bottom = 0;
	m_rCameraWorldPosition.left = 0;
	m_rCameraWorldPosition.right = 0;

	m_pObjectToFollow = 0;
}
CCamera::~CCamera()
{
}
void CCamera::Update()
{
	m_rCameraWorldPosition.left = (LONG)m_pObjectToFollow->GetPositionX() - (m_nCameraWidth/2);
	m_rCameraWorldPosition.top = (LONG)m_pObjectToFollow->GetPositionY() - (m_nCameraHeight/2);
	m_rCameraWorldPosition.right = m_rCameraWorldPosition.left + m_nCameraWidth;
	m_rCameraWorldPosition.bottom = m_rCameraWorldPosition.top + m_nCameraHeight;

	m_nCameraOffSetX = m_rCameraWorldPosition.left - m_nCameraScreenPositionX;
	m_nCameraOffSetY = m_rCameraWorldPosition.top - m_nCameraScreenPositionY;

}
void CCamera::InitializeCamera(int nScreenPosX, int nScreenPosY, int CameraWidth, int CameraHeight, BaseObject* ObjectToFollow)
{
	m_nCameraScreenPositionX = nScreenPosX;
	m_nCameraScreenPositionY = nScreenPosY;
	m_nCameraWidth = CameraWidth;
	m_nCameraHeight = CameraHeight;
	m_pObjectToFollow = ObjectToFollow;

	m_rCameraWorldPosition.left = (LONG)ObjectToFollow->GetPositionX() - (m_nCameraWidth/2);
	m_rCameraWorldPosition.top = (LONG)ObjectToFollow->GetPositionY() - (m_nCameraHeight/2);
	m_rCameraWorldPosition.right = m_rCameraWorldPosition.left + m_nCameraWidth;
	m_rCameraWorldPosition.bottom = m_rCameraWorldPosition.top + m_nCameraHeight;

	m_nCameraOffSetX = m_rCameraWorldPosition.left;
	m_nCameraOffSetY = m_rCameraWorldPosition.top;

}